var className;
$(function() {
	var data = window.sessionStorage.getItem('myData');
    if (!data) {
        window.location = 'login.html';
    } else {
    	data = JSON.parse(data);
    	console.log(data);
	    $('.className').click(function(){
	    	$('#container-game').html('<canvas width="800" height="600" id="canvas"></canvas>');
	    	className = this.id;
	    	sprites = sprites.setSprites(className);
	    	var url = 'http://ittalentsapi.bashibozuk.eu/game/game-start?user_id='+data.id+'&X-GameID=103';
	    	$.ajax(url, {
				method: 'GET',
				crossDomain : true,
				success: function(data) {
					console.log(data);
					console.log(data.id);
					var game = new Game(data.id,className);
					game.load();
				}
			});		
	    });	
    }
});